package com._58city.spark.app.ext.job;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com._58city.spark.app.ext.DaoUtil;
import com._58city.spark.app.ext.dto.DispCate;
import com._58city.spark.app.redis.Constant;
import com._58city.spark.app.redis.RedisUtil;


/**
 * @author lihao
 * spring维护的一个定时任务
 */
public class ExtJob {
	
	private Logger log = LoggerFactory.getLogger(ExtJob.class);
	
//	public void sync_disp_cate() {  
//        log.info("sync_disp_cate ....");
//        List<DispCate> list = DaoUtil.getDispCateDao().select_all();
//        Map<String, String> tmp = new HashMap<String, String>();
//        for(DispCate one : list){
//        	if (one.getCate_id() > 0) {
//				tmp.put(String.valueOf(one.getCate_id()), one.getBusiness_type_biz());
//			}
//        }
//        RedisUtil.cache.hMultiSetString(Constant.redis_cateid_business, tmp);
//    } 
	
	/**
	 * 由于cate字典表会有变化，所以定时同步到redis中
	 */
	public void sync_disp_cate() {  
        log.info("sync_disp_cate ....");
        List<DispCate> list = DaoUtil.getDispCateDao().select_all();
        Map<String, Object> tmp = new HashMap<String, Object>();
        for(DispCate one : list){
        	if (one.getCate_id() > 0) {
				tmp.put(String.valueOf(one.getCate_id()), one);
			}
        }
        RedisUtil.cache.hMultiSetObject(Constant.redis_cate_dict, tmp);
    }

}
